package com.wnhz.work.jy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.wnhz.work.jy.R;
import com.wnhz.work.jy.bean.AssetItemBean;

import java.util.List;

/**
 * Created by Administrator on 2016/11/7 0007.
 */
public class AssetItemAdapter extends BaseAdapter {
    private Context context;
    private List<AssetItemBean> list;

    public AssetItemAdapter(Context context, List<AssetItemBean> list) {
        this.context = context;
        this.list = list;
    }

    @Override

    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        AssetItemViewHolder viewHolder = new AssetItemViewHolder();
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.order_item, null);
            viewHolder.iv_img = (ImageView) convertView.findViewById(R.id.iv_img);
            viewHolder.tv_title = (TextView) convertView.findViewById(R.id.tv_title);
            viewHolder.tv_money = (TextView) convertView.findViewById(R.id.tv_money);
            viewHolder.tv_numbers = (TextView) convertView.findViewById(R.id.tv_numbers);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (AssetItemViewHolder) convertView.getTag();
        }

        ImageLoader.getInstance().displayImage(list.get(position).getGoodsImg(), viewHolder.iv_img);
        viewHolder.tv_title.setText(list.get(position).getGoodsName());
        viewHolder.tv_money.setText("¥ " + list.get(position).getGoodsPrice());
        viewHolder.tv_numbers.setText("x" + list.get(position).getGoodsNums());

        return convertView;
    }

    class AssetItemViewHolder {
        private ImageView iv_img;
        private TextView tv_title;
        private TextView tv_money;
        private TextView tv_numbers;
    }
}
